import ajax from '../network/fetch.js';
const BASE_URL = import.meta.env.VITE_BASE_URL;

const communityApi = {
  getCommunityList: '/getPostList',// 社区列表
  likePost: '/like',// 点赞
  getPostDetail: '/getPostDetail',// 帖子详情
  commentPost: '/commentPost',// 评论
  createPost: '/createPost',// 创建帖子
  getUserPostList: '/getUserPostList',// 用户帖子列表
  getCommentList: '/getCommentList',// 评论列表
  deleteComment: '/deleteComment',// 删除评论
  getAllLikes: '/getAllLikes',// 所有点赞
};

const userApi = {
  login: '/login',// 登录
  forgot: '/sendCode',// 忘记密码
  validateCode: '/validateCode',// 验证码
  register: '/register',// 注册 || 新增用户
  reset: '/resetPwd',// 重置密码
  profile: '/profile',// 用户信息
  allUser: '/allUser',// 所有用户
  freezeUser: '/freezeUser',// 冻结用户
  deleteUser: '/deleteUser',// 删除用户
};

const uploadApi = {
  upload: '/commonUpload',// 上传图片
  userAvatar: '/avatar'// 用户头像
};

const common ={
  getStatistics: '/getStatistics',// 统计数据
  getUserGrowthTrend: '/getUserGrowthTrend',// 用户增长趋势
  getPostPublishTrend: '/getPostPublishTrend',// 帖子发布趋势
}
const request = function(url, data, method) {
  const fullUrl = `${BASE_URL}${url}`; 
  return ajax(fullUrl, {
    data: data,
    method: method
  });
};
export default {
  communityApi,
  userApi,
  uploadApi,
  request,
  common
};